package com.lispiron.training.scclient.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @author QiYao
 * @date 2018/2/25
 */
@Service
public class HelloService {

    @Autowired
    RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "error")
    public String hello(){
        return restTemplate.getForEntity("http://service-auth/hello", String.class).getBody();
    }

    public String error(){
        return "error";
    }
}
